<template>
  <a-modal
    :title="title"
    :width="width"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">

    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{type:'radio',selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
      </a-table>
    </div>

  </a-modal>
</template>
<script>
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getAction} from "../../../api/manage";

export default {
  name: 'salaryTemplateInsuranceModal',
  mixins: [JeecgListMixin],
  components: {},
  data() {
    return {
      title: '社保模板',
      width: document.body.clientWidth * 0.8,
      confirmLoading: false,
      visible: false,
      description: '社保模板页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '模板名',
          align: "center",
          dataIndex: 'templateName',
        },
        {
          title: '保险基数',
          align: "center",
          dataIndex: 'insuranceBase',
        },
        {
          title: '公司比例医疗',
          align: "center",
          dataIndex: 'companyScaleYi',
        },
        {
          title: '个人比例医疗',
          align: "center",
          dataIndex: 'personalScaleYi',
        },
        {
          title: '公司比例养老',
          align: "center",
          dataIndex: 'companyScaleYang',
        },
        {
          title: '个人比例养老',
          align: "center",
          dataIndex: 'personalScaleYang',
        },
        {
          title: '公司比例工伤',
          align: "center",
          dataIndex: 'companyScaleShang',
        },
        {
          title: '个人比例工伤',
          align: "center",
          dataIndex: 'personalScaleShang',
        },
        {
          title: '公司比例失业',
          align: "center",
          dataIndex: 'companyScaleShi',
        },
        {
          title: '个人比例失业',
          align: "center",
          dataIndex: 'personalScaleShi',
        },
        {
          title: '公司比例生育',
          align: "center",
          dataIndex: 'companyScaleYu',
        },
        {
          title: '个人比例生育',
          align: "center",
          dataIndex: 'personalScaleYu',
        },
      ],
      url: {
        list: '/salaryconfigtemplate/salaryConfigTemplateInsurrance/list',
      },
      isCreatedLoadData: false,
    }
  },
  methods: {
    open() {
      this.visible = true
      this.loadData()
    },
    loadData(arg) {
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams(); //查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total
        } else {
          this.dataSource = []
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    handleCancel() {
      this.visible = false
      this.onClearSelected()
      this.dataSource = []
      this.isCreatedLoadData = false
      this.ipagination.current = 1
      this.ipagination.pageSize = 30
    },
    handleOk() {
      const that = this
      if (that.selectedRowKeys.length <= 0) {
        this.$message.destroy()
        that.$message.warning('请至少选择一条数据!')
        return
      } else {
        that.$emit('ok', this.selectionRows)
        that.handleCancel()
      }
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>